import static org.junit.Assert.*;

import org.junit.Test;


public class MainTest {
	/**
	 * @brief Test for function fib
	 * @param 
	 * @return 
	 * @author Sarper Sertoglu
	 */
	@Test
	public void testFib() {
		Main tester = new Main();
		assertEquals("1st fib number must be 1",1,tester.fib(1));
		assertEquals("2nd fib number must be 1",1,tester.fib(2));
		assertEquals("3rd fib number must be 1",2,tester.fib(3));
		assertEquals("4th fib number must be 1",3,tester.fib(4));
		assertEquals("5th fib number must be 1",5,tester.fib(5));
		assertEquals("6th fib number must be 1",8,tester.fib(6));
		assertEquals("7th fib number must be 1",13,tester.fib(7));
		assertEquals("8th fib number must be 1",21,tester.fib(8));
		assertEquals("23th fib number must be 1",28657,tester.fib(23));
		assertEquals("-5 fib number must be 1",1,tester.fib(-5));

	}
	@Test
	public void testCubeNum(){
		Main tester = new Main();
		assertEquals("cube of 2 must be 8",8, tester.cubeNum(2));
		assertEquals("cube of 5 must be 125",125, tester.cubeNum(5));
		assertEquals("cube of 10 must be 1000",1000, tester.cubeNum(10));
		assertEquals("cube of 6 must be 216",216, tester.cubeNum(6));
		assertEquals("cube of 13 must be 2197",2197, tester.cubeNum(13));
		assertEquals("cube of -4 must be -64",-64, tester.cubeNum(-4));
		assertEquals("cube of -8 must be -512",-512, tester.cubeNum(-8));
		assertEquals("cube of -12 must be -1728",-1728, tester.cubeNum(-12));
	
	}
	
	@Test
	public void testSumOfSquares() {
		Main tester = new Main();
		assertEquals("Sum of squares up to 0 has to be 0", 0, tester.sumOfSquares(0));
		assertEquals("Sum of squares up to 1 has to be 1", 1, tester.sumOfSquares(1));
		assertEquals("Sum of squares up to 2 has to be 5 ", 5, tester.sumOfSquares(2));
		assertEquals("Sum of squares up to 3 has to be 14", 14, tester.sumOfSquares(3));
		assertEquals("Sum of squares up to 4 has to be 30", 30, tester.sumOfSquares(4));
		assertEquals("Sum of squares up to 10 has to be 385", 385, tester.sumOfSquares(10));
		assertEquals("Sum of squares for a negative number has to be -1(not defined)", -1, tester.sumOfSquares(-1)); 
	}
	
	@Test
	public void testIsPrime(){
		Main tester = new Main();
		assertEquals("2 is prime",true, tester.isPrime(2));
		assertEquals("3 is prime",true, tester.isPrime(3));
		assertEquals("5 is prime",true, tester.isPrime(5));
		assertEquals("6 is not prime",false, tester.isPrime(6));
		assertEquals("7 is prime",true, tester.isPrime(7));
		assertEquals("11 is prime",true, tester.isPrime(11));
		assertEquals("100 is not prime",false, tester.isPrime(100));
		assertEquals("-2 is not prime",false, tester.isPrime(-2));
		assertEquals("-5 is not prime",false, tester.isPrime(-5));
		assertEquals("-10 is not prime",false, tester.isPrime(-10));
	}
	
	@Test
	public void testSign(){
		Main tester = new Main();
		assertEquals("Sign of -9 is -1", -1, tester.sign(-9));
		assertEquals("Sign of 0 is 0", 0, tester.sign(0));
		assertEquals("Sign of 112 is 1", 1, tester.sign(112));
		assertEquals("Sign of 1 is 1", 1, tester.sign(1));
		assertEquals("Sign of -1 is -1", -1, tester.sign(-1));
	}
	
	@Test
	public void testFindGCD() {
		Main tester = new Main();
		assertEquals("GCD of 2345 and 72 has to be 1", 1, tester.findGCD(2345,72));
		assertEquals("GCD of 1406700 and 164115 has to be 23445", 23445, tester.findGCD(1406700,164115));
		assertEquals("GCD of 1368 and 339 has to be 3", 3, tester.findGCD(1368,339));
		assertEquals("GCD of 55534 and 434334 has to be 2", 2, tester.findGCD(55534,434334));
		assertEquals("GCD of 243532 and 0 has to be 0", 243532, tester.findGCD(243532,0));
		assertEquals("GCD of 120 and 350 has to be 10", 10, tester.findGCD(120,350));
		assertEquals("GCD of 65 and -5 has to be -5", -5, tester.findGCD(65,-5));
	}
	
	@Test
	public void testFactorial(){
		Main tester = new Main();
		assertEquals("Factorial of 0 is 1", 1, tester.factorial(0));
		assertEquals("Factorial of 1 is 1", 1, tester.factorial(1));
		assertEquals("Factorial of 2 is 2", 2, tester.factorial(2));
		assertEquals("Factorial of 3 is 6", 6, tester.factorial(3));
		assertEquals("Factorial of 4 is 24", 24, tester.factorial(4));
		assertEquals("Factorial of 5 is 120", 120, tester.factorial(5));
		assertEquals("Factorial of -1 is 0(not defined)", 0, tester.factorial(-1));
	}
	
	@Test
	public void testDenemeBirKi(){
		Main tester = new Main();
		assertEquals("The quote should be:Time exists,but just on your wrists,so don't panic...","Time exists,but just on your wrists,so don't panic...",tester.denemeBirKi());	
	}
	
	@Test
	public void testICanCommit(){
		Main tester = new Main();
		assertEquals("If the input is Erdem, output should be:Welcome to Time Flies, Erdem","Welcome to Time Flies, Erdem",tester.iCanCommit("Erdem"));	
		assertEquals("If the input is Stranger, output should be:Welcome to Time Flies, Stranger","Welcome to Time Flies, Stranger",tester.iCanCommit("Stranger"));	
	}
}
